package com.yanxiaohui.springbootjdbc.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Description TODO
 * @Author： yanxh<br>
 * @Date 2019/11/7 10:25<br>
 * @Version 1.0<br>
 */
@Service
public class UserService {

    @Autowired
    JdbcTemplate jdbcTemplate;

    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public Boolean addUser(String name){
        int update = jdbcTemplate.update("insert into score_record(SCORE_NAME) values (?)", name);
        return update > 0;
    }
}
